//
//  AppTools.m
//  二次豆瓣
//
//  Created by dllo on 15/11/7.
//  Copyright © 2015年 angie. All rights reserved.
//

#import "AppTools.h"
#import "AFNetworking.h"

@implementation AppTools

+ (void)getDataWithURL:(NSString *)URLPath block:(AppToolBlock)block
{
    
    AFNetworkReachabilityManager *netWorkManager = [AFNetworkReachabilityManager sharedManager];
    
    NSString *url_string = [URLPath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    
    // 支持的接口类型
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    
    [manager GET:url_string parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [netWorkManager stopMonitoring];
        
        block(responseObject);
        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"电影列表解析失败==== %@",error);
        
    }];
    
    
}

@end
